{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "6da31eee",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting wfdb\n",
      "  Obtaining dependency information for wfdb from https://files.pythonhosted.org/packages/ce/00/b83d0bd64384455dbc1f8eccb7b5d6dac23728515a9d4d74aa4def6c6fe4/wfdb-4.1.2-py3-none-any.whl.metadata\n",
      "  Using cached wfdb-4.1.2-py3-none-any.whl.metadata (4.3 kB)\n",
      "Collecting SoundFile>=0.10.0 (from wfdb)\n",
      "  Using cached soundfile-0.12.1-py2.py3-none-win_amd64.whl (1.0 MB)\n",
      "Requirement already satisfied: matplotlib>=3.2.2 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from wfdb) (3.8.0)\n",
      "Requirement already satisfied: numpy>=1.10.1 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from wfdb) (1.26.0)\n",
      "Requirement already satisfied: pandas>=1.3.0 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from wfdb) (2.1.1)\n",
      "Requirement already satisfied: requests>=2.8.1 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from wfdb) (2.31.0)\n",
      "Requirement already satisfied: scipy>=1.0.0 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from wfdb) (1.11.3)\n",
      "Requirement already satisfied: contourpy>=1.0.1 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from matplotlib>=3.2.2->wfdb) (1.1.1)\n",
      "Requirement already satisfied: cycler>=0.10 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from matplotlib>=3.2.2->wfdb) (0.12.0)\n",
      "Requirement already satisfied: fonttools>=4.22.0 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from matplotlib>=3.2.2->wfdb) (4.43.0)\n",
      "Requirement already satisfied: kiwisolver>=1.0.1 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from matplotlib>=3.2.2->wfdb) (1.4.5)\n",
      "Requirement already satisfied: packaging>=20.0 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from matplotlib>=3.2.2->wfdb) (23.1)\n",
      "Requirement already satisfied: pillow>=6.2.0 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from matplotlib>=3.2.2->wfdb) (10.0.1)\n",
      "Requirement already satisfied: pyparsing>=2.3.1 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from matplotlib>=3.2.2->wfdb) (3.1.1)\n",
      "Requirement already satisfied: python-dateutil>=2.7 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from matplotlib>=3.2.2->wfdb) (2.8.2)\n",
      "Requirement already satisfied: pytz>=2020.1 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from pandas>=1.3.0->wfdb) (2023.3.post1)\n",
      "Requirement already satisfied: tzdata>=2022.1 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from pandas>=1.3.0->wfdb) (2023.3)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from requests>=2.8.1->wfdb) (3.3.0)\n",
      "Requirement already satisfied: idna<4,>=2.5 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from requests>=2.8.1->wfdb) (3.4)\n",
      "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from requests>=2.8.1->wfdb) (2.0.6)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from requests>=2.8.1->wfdb) (2023.7.22)\n",
      "Requirement already satisfied: cffi>=1.0 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from SoundFile>=0.10.0->wfdb) (1.15.1)\n",
      "Requirement already satisfied: pycparser in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from cffi>=1.0->SoundFile>=0.10.0->wfdb) (2.21)\n",
      "Requirement already satisfied: six>=1.5 in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from python-dateutil>=2.7->matplotlib>=3.2.2->wfdb) (1.16.0)\n",
      "Using cached wfdb-4.1.2-py3-none-any.whl (159 kB)\n",
      "Installing collected packages: SoundFile, wfdb\n",
      "Successfully installed SoundFile-0.12.1 wfdb-4.1.2\n"
     ]
    }
   ],
   "source": [
    "!pip install wfdb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "dbd9c8fb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting plotly\n",
      "  Obtaining dependency information for plotly from https://files.pythonhosted.org/packages/df/79/c80174d711ee26ee5da55a9cc3e248f1ec7a0188b5e4d6bbbbcd09b974b0/plotly-5.17.0-py2.py3-none-any.whl.metadata\n",
      "  Downloading plotly-5.17.0-py2.py3-none-any.whl.metadata (7.0 kB)\n",
      "Collecting tenacity>=6.2.0 (from plotly)\n",
      "  Obtaining dependency information for tenacity>=6.2.0 from https://files.pythonhosted.org/packages/f4/f1/990741d5bb2487d529d20a433210ffa136a367751e454214013b441c4575/tenacity-8.2.3-py3-none-any.whl.metadata\n",
      "  Downloading tenacity-8.2.3-py3-none-any.whl.metadata (1.0 kB)\n",
      "Requirement already satisfied: packaging in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from plotly) (23.1)\n",
      "Downloading plotly-5.17.0-py2.py3-none-any.whl (15.6 MB)\n",
      "   ---------------------------------------- 0.0/15.6 MB ? eta -:--:--\n",
      "   ---------------------------------------- 0.1/15.6 MB 1.7 MB/s eta 0:00:10\n",
      "   - -------------------------------------- 0.4/15.6 MB 5.4 MB/s eta 0:00:03\n",
      "   -- ------------------------------------- 0.9/15.6 MB 7.0 MB/s eta 0:00:03\n",
      "   --- ------------------------------------ 1.4/15.6 MB 7.9 MB/s eta 0:00:02\n",
      "   ---- ----------------------------------- 1.6/15.6 MB 7.2 MB/s eta 0:00:02\n",
      "   ----- ---------------------------------- 2.0/15.6 MB 7.4 MB/s eta 0:00:02\n",
      "   ------ --------------------------------- 2.4/15.6 MB 8.0 MB/s eta 0:00:02\n",
      "   ------ --------------------------------- 2.7/15.6 MB 7.8 MB/s eta 0:00:02\n",
      "   ------- -------------------------------- 3.0/15.6 MB 7.7 MB/s eta 0:00:02\n",
      "   -------- ------------------------------- 3.3/15.6 MB 7.6 MB/s eta 0:00:02\n",
      "   -------- ------------------------------- 3.4/15.6 MB 7.5 MB/s eta 0:00:02\n",
      "   --------- ------------------------------ 3.6/15.6 MB 7.2 MB/s eta 0:00:02\n",
      "   --------- ------------------------------ 3.8/15.6 MB 6.6 MB/s eta 0:00:02\n",
      "   ---------- ----------------------------- 3.9/15.6 MB 6.4 MB/s eta 0:00:02\n",
      "   ---------- ----------------------------- 4.1/15.6 MB 6.1 MB/s eta 0:00:02\n",
      "   ----------- ---------------------------- 4.3/15.6 MB 6.0 MB/s eta 0:00:02\n",
      "   ----------- ---------------------------- 4.5/15.6 MB 6.0 MB/s eta 0:00:02\n",
      "   ----------- ---------------------------- 4.7/15.6 MB 5.9 MB/s eta 0:00:02\n",
      "   ------------ --------------------------- 5.0/15.6 MB 5.9 MB/s eta 0:00:02\n",
      "   ------------- -------------------------- 5.3/15.6 MB 5.9 MB/s eta 0:00:02\n",
      "   -------------- ------------------------- 5.5/15.6 MB 5.9 MB/s eta 0:00:02\n",
      "   -------------- ------------------------- 5.8/15.6 MB 5.9 MB/s eta 0:00:02\n",
      "   --------------- ------------------------ 6.1/15.6 MB 5.9 MB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 6.3/15.6 MB 5.9 MB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 6.6/15.6 MB 5.9 MB/s eta 0:00:02\n",
      "   ----------------- ---------------------- 6.9/15.6 MB 5.9 MB/s eta 0:00:02\n",
      "   ----------------- ---------------------- 7.0/15.6 MB 5.8 MB/s eta 0:00:02\n",
      "   ------------------ --------------------- 7.3/15.6 MB 5.8 MB/s eta 0:00:02\n",
      "   ------------------- -------------------- 7.6/15.6 MB 5.9 MB/s eta 0:00:02\n",
      "   -------------------- ------------------- 8.0/15.6 MB 6.0 MB/s eta 0:00:02\n",
      "   --------------------- ------------------ 8.5/15.6 MB 6.1 MB/s eta 0:00:02\n",
      "   ---------------------- ----------------- 8.8/15.6 MB 6.1 MB/s eta 0:00:02\n",
      "   ----------------------- ---------------- 9.3/15.6 MB 6.3 MB/s eta 0:00:02\n",
      "   ------------------------ --------------- 9.5/15.6 MB 6.3 MB/s eta 0:00:01\n",
      "   ------------------------- -------------- 9.9/15.6 MB 6.3 MB/s eta 0:00:01\n",
      "   -------------------------- ------------- 10.2/15.6 MB 6.3 MB/s eta 0:00:01\n",
      "   -------------------------- ------------- 10.5/15.6 MB 6.4 MB/s eta 0:00:01\n",
      "   --------------------------- ------------ 10.9/15.6 MB 6.4 MB/s eta 0:00:01\n",
      "   ----------------------------- ---------- 11.4/15.6 MB 6.4 MB/s eta 0:00:01\n",
      "   ------------------------------ --------- 11.8/15.6 MB 6.4 MB/s eta 0:00:01\n",
      "   ------------------------------ --------- 12.1/15.6 MB 6.4 MB/s eta 0:00:01\n",
      "   ------------------------------- -------- 12.4/15.6 MB 6.4 MB/s eta 0:00:01\n",
      "   -------------------------------- ------- 12.8/15.6 MB 6.5 MB/s eta 0:00:01\n",
      "   ---------------------------------- ----- 13.3/15.6 MB 6.5 MB/s eta 0:00:01\n",
      "   ----------------------------------- ---- 13.8/15.6 MB 6.7 MB/s eta 0:00:01\n",
      "   ------------------------------------ --- 14.3/15.6 MB 7.2 MB/s eta 0:00:01\n",
      "   ------------------------------------- -- 14.7/15.6 MB 7.5 MB/s eta 0:00:01\n",
      "   -------------------------------------- - 15.0/15.6 MB 7.6 MB/s eta 0:00:01\n",
      "   ---------------------------------------  15.4/15.6 MB 7.7 MB/s eta 0:00:01\n",
      "   ---------------------------------------  15.6/15.6 MB 7.8 MB/s eta 0:00:01\n",
      "   ---------------------------------------- 15.6/15.6 MB 7.6 MB/s eta 0:00:00\n",
      "Downloading tenacity-8.2.3-py3-none-any.whl (24 kB)\n",
      "Installing collected packages: tenacity, plotly\n",
      "Successfully installed plotly-5.17.0 tenacity-8.2.3\n"
     ]
    }
   ],
   "source": [
    "!pip install plotly"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "cbc79186",
   "metadata": {},
   "outputs": [],
   "source": [
    "import wfdb\n",
    "import os\n",
    "import numpy as np\n",
    "import fnmatch\n",
    "import pandas as pd\n",
    "# from plotly.subplots import make_subplots\n",
    "# import plotly.graph_objects as go\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 176,
   "id": "c88de42d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'E:/ECG-ID/Data bersih 1 - Copy (146)/'"
      ]
     },
     "execution_count": 176,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "file_path = 'E:/ECG-ID/Data bersih 1 - Copy (146)/'\n",
    "file_path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "id": "c5dfa42b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'3180470'"
      ]
     },
     "execution_count": 177,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c_folder = os.listdir(file_path)\n",
    "filename = ', '.join(c_folder)\n",
    "filename = filename.replace('[', '').replace(']', '').replace(\"'\", '')\n",
    "filename"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 178,
   "id": "258f34a6",
   "metadata": {},
   "outputs": [],
   "source": [
    "#step 1\n",
    "# Read through folders\n",
    "take_dat = \"*.dat\"\n",
    "data = []\n",
    "file_in_folder = [fnmatch.filter(os.listdir(file_path+\"%s\" %f), take_dat) for f in c_folder]\n",
    "for idx, f in enumerate(c_folder):\n",
    "  data.append(list(map(lambda x: f + \"/\" + x, file_in_folder[idx])))\n",
    "\n",
    "data = [f.split(\".\")[0] for x in data for f in x]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "id": "c174ec4f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['3178573/3178573n',\n",
       " '3178573/3178573_0001',\n",
       " '3178573/3178573_0002',\n",
       " '3178573/3178573_0003',\n",
       " '3178573/3178573_0004',\n",
       " '3178573/3178573_0005',\n",
       " '3178573/3178573_0006',\n",
       " '3178573/3178573_0007',\n",
       " '3178573/3178573_0008',\n",
       " '3178573/3178573_0009',\n",
       " '3178573/3178573_0010',\n",
       " '3178573/3178573_0011',\n",
       " '3178573/3178573_0012',\n",
       " '3178573/3178573_0013',\n",
       " '3178573/3178573_0014',\n",
       " '3178573/3178573_0015']"
      ]
     },
     "execution_count": 124,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 179,
   "id": "4f26f14f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Read dat file\n",
    "complete = []\n",
    "data_error = []\n",
    "for f in data:\n",
    "#     print(f)\n",
    "   try :\n",
    "#       name = wfdb.rdrecord(\"D:/MIMIC III CNN Prediction/cek/Data bersih 1 - Copy (146)/%s\" %(f)).__dict__['sig_name']\n",
    "      name = wfdb.rdrecord(file_path+\"%s\" %(f), sampfrom = 0, sampto = 60000).__dict__['sig_name']\n",
    "      if (len(name) == 3) and (\"ABP\" in name) and (\"II\" in name) and (\"PLETH\" in name):\n",
    "        complete.append(file_path+\"%s\" %(f))\n",
    "   except ValueError as e:\n",
    "    data_error.append(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "77a34573",
   "metadata": {},
   "outputs": [],
   "source": [
    "from scipy.signal import find_peaks"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 180,
   "id": "863e8c19",
   "metadata": {},
   "outputs": [],
   "source": [
    "# from plotly.subplots import make_subplots\n",
    "# import plotly.graph_objects as go\n",
    "\n",
    "dataset = []\n",
    "\n",
    "for f in complete:\n",
    "\n",
    "  try:\n",
    "    sig = wfdb.rdrecord(f, sampfrom = 0, sampto = 60000).__dict__['p_signal']\n",
    "#     sig = wfdb.rdrecord(f).__dict__['p_signal']\n",
    "    sig = np.array(sig).T\n",
    "#     print(sig)\n",
    "    if ~np.isnan(sig).any():\n",
    "      dataset.append(f)\n",
    "  except ValueError :\n",
    "    print(f)\n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "46190122",
   "metadata": {},
   "source": [
    "# Simpan_ECG"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 181,
   "id": "4d451d43",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjgAAAGdCAYAAAAfTAk2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAABBSUlEQVR4nO3deXhU1eH/8c/NNgmRDISQTUIICGEJSwiQBYkiGHaltRIU4lLE0oKA6K8al7r0W6N2wxXFWilVAduA4ldAQsuiJeAXSHBHrNggJqVSyABKwnJ/f0SGTGayMpPl8n49z30e5s6Zc889TGY+c+659xqmaZoCAACwEL+WbgAAAIC3EXAAAIDlEHAAAIDlEHAAAIDlEHAAAIDlEHAAAIDlEHAAAIDlEHAAAIDlBLR0A1rCmTNn9PXXX6t9+/YyDKOlmwMAABrANE0dPXpUsbGx8vOre4zmggw4X3/9teLi4lq6GQAAoAn279+vLl261Fnmggw47du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HjhwxAwMDzeXLlzvLHDhwwPTz8zPXrVtnmqZpfvzxx6Ykc9u2bc4yhYWFpiTz008/NU2zKmj5+fmZBw4ccJZZtmyZabPZzPLycp/s7/k6ePCgKcncvHmzaZr0V306duxo/uEPf6CfanH06FGzZ8+eZkFBgXnZZZc5Aw795eqBBx4wBw4c6PE5+srVXXfdZV566aW1Pt8W+4tDVF5QWVmpnTt3Kisry2V9VlaWtm7d2kKtal779u1TWVmZSx/YbDZddtllzj7YuXOnTp486VImNjZWSUlJzjKFhYWy2+1KTU11lklLS5Pdbncpk5SUpNjYWGeZMWPGqKKiwmU4tTUpLy+XJIWHh0uiv2pz+vRpLV++XMePH1d6ejr9VIvZs2drwoQJGj16tMt6+svd3r17FRsbq4SEBE2dOlVffPGFJPqqptWrV2vIkCG69tprFRkZqeTkZL3wwgvO59tifxFwvOCbb77R6dOnFRUV5bI+KipKZWVlLdSq5nV2P+vqg7KyMgUFBaljx451lomMjHSrPzIy0qVMze107NhRQUFBrbK/TdPUggULdOmllyopKUkS/VXTBx98oIsuukg2m02zZs3SqlWr1LdvX/rJg+XLl2vXrl3Ky8tze47+cpWamqqlS5fq7bff1gsvvKCysjJlZGTo0KFD9FUNX3zxhRYtWqSePXvq7bff1qxZszR37lwtXbpUUtt8b12QdxP3FcMwXB6bpum2zuqa0gc1y3gq35QyrcWcOXP0/vvv691333V7jv6qkpiYqOLiYh05ckT5+fm68cYbtXnzZufz9FOV/fv3a968eVq/fr2Cg4NrLUd/VRk3bpzz3/3791d6erp69OihP/3pT0pLS5NEX5115swZDRkyRI888ogkKTk5WR999JEWLVqkG264wVmuLfUXIzheEBERIX9/f7dkefDgQbcUalVnz0yoqw+io6NVWVmpw4cP11nm3//+t1v9//nPf1zK1NzO4cOHdfLkyVbX37fddptWr16tjRs3qkuXLs719JeroKAgXXLJJRoyZIjy8vI0cOBAPfHEE/RTDTt37tTBgweVkpKigIAABQQEaPPmzXryyScVEBDgbCf95VloaKj69++vvXv38t6qISYmRn379nV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"text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "df_ECG = pd.DataFrame({'nilai_sig': sig[0]})\n",
    "\n",
    "# Tampilkan plot dari sig[0]\n",
    "plt.plot(df_ECG['nilai_sig'])\n",
    "# plt.xlim(9000,20000)\n",
    "plt.show()\n",
    "\n",
    "# Opsional: Simpan dataframe ke dalam file CSV jika diperlukan\n",
    "# df.to_csv('sig_data.csv', index=False)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 182,
   "id": "a7984e39",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "60000"
      ]
     },
     "execution_count": 182,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ECG_sig = sig[0]\n",
    "len(ECG_sig)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 183,
   "id": "83581462",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([-0.14173228, -0.14173228, -0.14173228, ..., -0.1023622 ,\n",
       "       -0.1023622 , -0.1023622 ])"
      ]
     },
     "execution_count": 183,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ECG_sig"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 184,
   "id": "41c24426",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_ECG = pd.DataFrame(ECG_sig)\n",
    "df_ECG = df_ECG.transpose()\n",
    "df_ECG.to_csv('C:/Users/aimedic/PycharmProjects/ecg_Project/mimic-iii/'+filename+'.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "id": "7595c25d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>39990</th>\n",
       "      <th>39991</th>\n",
       "      <th>39992</th>\n",
       "      <th>39993</th>\n",
       "      <th>39994</th>\n",
       "      <th>39995</th>\n",
       "      <th>39996</th>\n",
       "      <th>39997</th>\n",
       "      <th>39998</th>\n",
       "      <th>39999</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.341176</td>\n",
       "      <td>0.34902</td>\n",
       "      <td>0.360784</td>\n",
       "      <td>0.364706</td>\n",
       "      <td>0.372549</td>\n",
       "      <td>0.384314</td>\n",
       "      <td>0.396078</td>\n",
       "      <td>0.403922</td>\n",
       "      <td>0.407843</td>\n",
       "      <td>0.415686</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.807843</td>\n",
       "      <td>0.458824</td>\n",
       "      <td>0.254902</td>\n",
       "      <td>0.223529</td>\n",
       "      <td>0.262745</td>\n",
       "      <td>0.305882</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.352941</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1 rows × 40000 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      0        1         2         3         4         5         6      \\\n",
       "0  0.341176  0.34902  0.360784  0.364706  0.372549  0.384314  0.396078   \n",
       "\n",
       "      7         8         9      ...  39990  39991     39992     39993  \\\n",
       "0  0.403922  0.407843  0.415686  ...    1.0    1.0  0.807843  0.458824   \n",
       "\n",
       "      39994     39995     39996     39997     39998     39999  \n",
       "0  0.254902  0.223529  0.262745  0.305882  0.333333  0.352941  \n",
       "\n",
       "[1 rows x 40000 columns]"
      ]
     },
     "execution_count": 153,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_ECG"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "60772d40",
   "metadata": {},
   "source": [
    "*************************************** selesai **********************************"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "55915786",
   "metadata": {},
   "outputs": [],
   "source": [
    "distance_mean_median = []\n",
    "clean_dataset = []\n",
    "\n",
    "\n",
    "for f in dataset:\n",
    "  sig = wfdb.rdrecord(f, sampfrom =  0, sampto = 100000).__dict__['p_signal']\n",
    "#   sig = wfdb.rdrecord(f)\n",
    "  sig = np.array(sig).T\n",
    "  peaks, _ = find_peaks(sig[1], distance=60)\n",
    "  if (sig[1] == 0).all() :\n",
    "    pass\n",
    "  else:\n",
    "\n",
    "    if (sig[1][peaks]).std() < 10:\n",
    "        clean_dataset.append(f)\n",
    "    dist =  abs((sig[1][peaks]).mean() - np.median(sig[1][peaks], axis=None))\n",
    "    distance_mean_median.append(dist)\n",
    "#     print(\"\\n \", f)\n",
    "#     print(\"=\"*100)\n",
    "#     print(\"\\nNilai mean peak: \", (sig[1][peaks]).mean() )\n",
    "#     print(\"Nilai median peak: \", np.median(sig[1][peaks], axis=None) )\n",
    "#     print(\"Nilai std peak: \", (sig[1][peaks]).std() )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "4fe9a192",
   "metadata": {},
   "outputs": [],
   "source": [
    "for f in clean_dataset:\n",
    "    sig = wfdb.rdrecord(f, sampfrom =  0, sampto = 100000).__dict__['p_signal']\n",
    "#     sig = wfdb.rdrecord(f).__dict__['p_signal']\n",
    "    sig = np.array(sig).T\n",
    "    peaks, _ = find_peaks(sig[2], distance=60)\n",
    "    bottom, _ = find_peaks(-sig[2], distance=60)\n",
    "  \n",
    "    fig = make_subplots(rows=2, cols=1,\n",
    "                          subplot_titles=( \"PPG\", \"ABP\"))\n",
    "\n",
    "\n",
    "    fig.append_trace(go.Scatter(\n",
    "        y=sig[2], name=\"PPG\"\n",
    "    ), row=1, col=1)\n",
    "\n",
    "\n",
    "    fig.append_trace(go.Scatter(\n",
    "        y=sig[1], name=\"ABP\"\n",
    "    ), row=2, col=1)\n",
    "    \n",
    "    fig.add_trace(go.Scatter(\n",
    "        y=[sig[1][j] for j in peaks ],\n",
    "        x=peaks, mode='markers', marker_symbol='x-dot',\n",
    "        marker={'size':10},\n",
    "    ), row=2, col=1)\n",
    "\n",
    "    fig.add_trace(go.Scatter(\n",
    "        y=[sig[1][j] for j in bottom ],\n",
    "        x=bottom, mode='markers', marker_symbol='x-dot',\n",
    "        marker={'size':10,\n",
    "                'color' : 'LightSkyBlue'},\n",
    "    ), row=2, col=1)\n",
    "\n",
    " \n",
    "    fig.update_layout(height=800, width=800, title_text=f)\n",
    "    fig.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "49c5e9a4",
   "metadata": {},
   "outputs": [],
   "source": [
    "#clean_dataset #struktur path\n",
    "#ambil kedua dari kanan\n",
    "patient = []\n",
    "for patient_1 in (clean_dataset): #zip :dua list digabung jadi satu\n",
    "    simpan_patient = patient_1.split('/')\n",
    "    data_split = simpan_patient[7]\n",
    "    patient.append(data_split)\n",
    "#1.pisahin string\n",
    "#2. pake split\n",
    "#gimana cara ngeekstrak string kedua dari tengah"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "5b0e8833",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "patient"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "8fd6661a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting py-ecg-detectors\n",
      "  Using cached py_ecg_detectors-1.3.4-py3-none-any.whl (25 kB)\n",
      "Collecting gatspy (from py-ecg-detectors)\n",
      "  Using cached gatspy-0.3-py3-none-any.whl\n",
      "Requirement already satisfied: numpy in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from py-ecg-detectors) (1.26.0)\n",
      "Requirement already satisfied: pywavelets in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from py-ecg-detectors) (1.4.1)\n",
      "Requirement already satisfied: scipy in c:\\users\\aimedic\\anaconda3\\envs\\ecg_project\\lib\\site-packages (from py-ecg-detectors) (1.11.3)\n",
      "Installing collected packages: gatspy, py-ecg-detectors\n",
      "Successfully installed gatspy-0.3 py-ecg-detectors-1.3.4\n"
     ]
    }
   ],
   "source": [
    "!pip install py-ecg-detectors"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "bc08815e",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'data_split' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[57], line 30\u001b[0m\n\u001b[0;32m     25\u001b[0m PPG \u001b[38;5;241m=\u001b[39m []\n\u001b[0;32m     26\u001b[0m PPG_filter \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m---> 30\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m f, p \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mzip\u001b[39m (clean_dataset, \u001b[43mdata_split\u001b[49m):\n\u001b[0;32m     31\u001b[0m     data \u001b[38;5;241m=\u001b[39m wfdb\u001b[38;5;241m.\u001b[39mrdrecord(f, sampfrom \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m, sampto \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m100000\u001b[39m)\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__dict__\u001b[39m[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mp_signal\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[0;32m     32\u001b[0m     data \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39marray(data)\u001b[38;5;241m.\u001b[39m T\n",
      "\u001b[1;31mNameError\u001b[0m: name 'data_split' is not defined"
     ]
    }
   ],
   "source": [
    "## import pandas as pd\n",
    "import numpy as np\n",
    "from scipy.signal import find_peaks\n",
    "from plotly.subplots import make_subplots\n",
    "import plotly.graph_objects as go\n",
    "from ecgdetectors import Detectors\n",
    "from scipy.signal import  lfilter, cheby2\n",
    "\n",
    "fs = 125\n",
    "PPG_SBP = []\n",
    "PPG_DBP = []\n",
    "PPG = []\n",
    "ABP = []\n",
    "index = 0\n",
    "hasil_list_PPG = []\n",
    "table_signal = pd.DataFrame()\n",
    "signal_sbp_dbp = []\n",
    "SBP = []\n",
    "DBP = []\n",
    "average_SBP = []\n",
    "average_DBP = []\n",
    "detectors = Detectors (fs)\n",
    "lowcut = 0.5\n",
    "highcut = 10\n",
    "PPG = []\n",
    "PPG_filter = []\n",
    "\n",
    "\n",
    "\n",
    "for f, p in zip (clean_dataset, data_split):\n",
    "    data = wfdb.rdrecord(f, sampfrom = 0, sampto = 100000).__dict__['p_signal']\n",
    "    data = np.array(data). T\n",
    "    sinyal_ABP = data[1]\n",
    "    sinyal_PPG = data[2]\n",
    "    sinyal_ECG = data[0]\n",
    "         "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fc6c4d64",
   "metadata": {},
   "outputs": [],
   "source": [
    "sinyal_ECG"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "08d2ac88",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_ECG = pd.DataFrame(sinyal_ECG)\n",
    "ECG_horizontal = df_ECG.transpose()\n",
    "ECG_horizontal\n",
    "ECG_horizontal.to_csv('D:/ana/ECG-3901254.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a88d454e",
   "metadata": {},
   "outputs": [],
   "source": [
    "ECG_horizontal"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f502827c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# ## import pandas as pd\n",
    "# import numpy as np\n",
    "# from scipy.signal import find_peaks\n",
    "# from plotly.subplots import make_subplots\n",
    "# import plotly.graph_objects as go\n",
    "# # from ecgdetectors import Detectors\n",
    "# from scipy.signal import  lfilter, cheby2\n",
    "\n",
    "# fs = 125\n",
    "# PPG_SBP = []\n",
    "# PPG_DBP = []\n",
    "# PPG = []\n",
    "# ABP = []\n",
    "# index = 0\n",
    "# hasil_list_PPG = []\n",
    "# table_signal = pd.DataFrame()\n",
    "# signal_sbp_dbp = []\n",
    "# SBP = []\n",
    "# DBP = []\n",
    "# average_SBP = []\n",
    "# average_DBP = []\n",
    "# detectors = Detectors (fs)\n",
    "# lowcut = 0.5\n",
    "# highcut = 10\n",
    "# PPG = []\n",
    "# PPG_filter = []\n",
    "\n",
    "\n",
    "\n",
    "# for f, p in zip (clean_dataset, data_split):\n",
    "#     data = wfdb.rdrecord(f, sampfrom = 0, sampto = 37500).__dict__['p_signal']\n",
    "#     data = np.array(data). T\n",
    "#     sinyal_ABP = data[1]\n",
    "#     sinyal_PPG = data[2]\n",
    "# #     sinyal_ECG = data[0]\n",
    "#     ppg_peaks,_ = find_peaks(sinyal_PPG, distance=60)\n",
    "    \n",
    "    \n",
    "#     start = 0\n",
    "#     end = 2\n",
    "    \n",
    "    \n",
    "#     for i in range (len(ppg_peaks)-1):\n",
    "#          #untuk handle error\n",
    "#          try: \n",
    "            \n",
    "#              PPG.append(sinyal_PPG[ppg_peaks[start]: ppg_peaks[end]])    \n",
    "#              ABP.append(sinyal_ABP[ppg_peaks[start]: ppg_peaks[end]])\n",
    "            \n",
    "#          except IndexError:\n",
    "             \n",
    "#              PPG.append(sinyal_PPG[ppg_peaks[start]: ppg_peaks[end-1]])\n",
    "#              ABP.append(sinyal_ABP[ppg_peaks[start]: ppg_peaks[end-1]])\n",
    "         \n",
    "             \n",
    "#          conv_ABP = np.hstack(ABP)\n",
    "#          sbp_peaks, _ = find_peaks(conv_ABP, distance =60)\n",
    "#          dbp_peaks, _ = find_peaks(-conv_ABP, distance = 60) \n",
    "            \n",
    "             \n",
    "        \n",
    "#          SBP.append(conv_ABP [sbp_peaks[start]])\n",
    "#          DBP.append(conv_ABP [dbp_peaks[start]])\n",
    "        \n",
    "#          print(start,end)\n",
    "            \n",
    "#          start = start+1\n",
    "#          end = end+1\n",
    "         \n",
    "\n",
    "         "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "139cfffd",
   "metadata": {},
   "outputs": [],
   "source": [
    "# ## import pandas as pd\n",
    "# import numpy as np\n",
    "# from scipy.signal import find_peaks\n",
    "# from plotly.subplots import make_subplots\n",
    "# import plotly.graph_objects as go\n",
    "# from ecgdetectors import Detectors\n",
    "# from scipy.signal import  lfilter, cheby2\n",
    "# from tqdm import tqdm as progressBar\n",
    "\n",
    "# fs = 125\n",
    "# PPG_SBP = []\n",
    "# PPG_DBP = []\n",
    "# PPG = []\n",
    "# ABP = []\n",
    "# index = 0\n",
    "# hasil_list_PPG = []\n",
    "# table_signal = pd.DataFrame()\n",
    "# signal_sbp_dbp = []\n",
    "# SBP = []\n",
    "# DBP = []\n",
    "# average_SBP = []\n",
    "# average_DBP = []\n",
    "# detectors = Detectors (fs)\n",
    "# PPG = []\n",
    "# PPG_filter = []\n",
    "# pasien = []\n",
    "# temp_PPG = []\n",
    "# temp_SBP = []\n",
    "# temp_DBP = []\n",
    "\n",
    "\n",
    "\n",
    "# for f, p in progressBar(zip(clean_dataset, patient)):\n",
    "# #     print (p)\n",
    "#     data = wfdb.rdrecord(f, sampfrom = 0, sampto = 3750).__dict__['p_signal']\n",
    "#     data = np.array(data). T\n",
    "#     sinyal_ABP = data[1]\n",
    "#     sinyal_PPG = data[2]\n",
    "# #     sinyal_ECG = data[0]\n",
    "#     ppg_peaks,_ = find_peaks(sinyal_PPG, distance=60)\n",
    "    \n",
    "    \n",
    "#     start = 0\n",
    "#     end = 2\n",
    "    \n",
    "    \n",
    "#     for i in range (len(ppg_peaks)-1):\n",
    "#         pasien.append(p)\n",
    "#          #untuk handle error\n",
    "#         try: \n",
    "            \n",
    "#             PPG.append(sinyal_PPG[ppg_peaks[start]: ppg_peaks[end]])    \n",
    "#             ABP.append(sinyal_ABP[ppg_peaks[start]: ppg_peaks[end]])\n",
    "               \n",
    "                \n",
    "#         except IndexError:\n",
    "             \n",
    "#             PPG.append(sinyal_PPG[ppg_peaks[start]: ppg_peaks[end-1]])\n",
    "# #             temp_PPG = pd.DataFrame(PPG)\n",
    "# #             temp_PPG.insert(loc=0, column='patient', value= pasien)\n",
    "            \n",
    "            \n",
    "            \n",
    "#             ABP.append(sinyal_ABP[ppg_peaks[start]: ppg_peaks[end-1]])\n",
    "             \n",
    "             \n",
    "#         conv_ABP = np.hstack(ABP)\n",
    "#         sbp_peaks, _ = find_peaks(conv_ABP, distance =60)\n",
    "#         dbp_peaks, _ = find_peaks(-conv_ABP, distance = 60) \n",
    "            \n",
    "             \n",
    "        \n",
    "#         SBP.append(conv_ABP [sbp_peaks[start]])\n",
    "#         DBP.append(conv_ABP [dbp_peaks[start]])\n",
    "        \n",
    "    \n",
    "            \n",
    "# #         print(start,end)\n",
    "            \n",
    "#         start = start+1\n",
    "#         end = end+1\n",
    "            \n",
    "         \n",
    "\n",
    "\n",
    "         "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "204a8dab",
   "metadata": {},
   "outputs": [],
   "source": [
    "# ######################## BASED ON THE R-R INTERVAL #######################################\n",
    "\n",
    "\n",
    "# ## import pandas as pd\n",
    "# import numpy as np\n",
    "# from scipy.signal import find_peaks\n",
    "# from plotly.subplots import make_subplots\n",
    "# import plotly.graph_objects as go\n",
    "# from ecgdetectors import Detectors\n",
    "# from scipy.signal import  lfilter, cheby2\n",
    "\n",
    "# fs = 125\n",
    "# PPG_SBP = []\n",
    "# PPG_DBP = []\n",
    "# PPG = []\n",
    "# ABP = []\n",
    "# ECG = []\n",
    "# index = 0\n",
    "# hasil_list_PPG = []\n",
    "# table_signal = pd.DataFrame()\n",
    "# signal_sbp_dbp = []\n",
    "# SBP = []\n",
    "# DBP = []\n",
    "# average_SBP = []\n",
    "# average_DBP = []\n",
    "# detectors = Detectors (fs)\n",
    "# lowcut = 0.5\n",
    "# highcut = 10\n",
    "# PPG = []\n",
    "# PPG_filter = []\n",
    "\n",
    "\n",
    "\n",
    "# for f, p in zip (clean_dataset, data_split):\n",
    "#     data = wfdb.rdrecord(f, sampfrom = 0, sampto = 37500).__dict__['p_signal']\n",
    "#     data = np.array(data). T\n",
    "#     sinyal_ABP = data[1]\n",
    "#     sinyal_PPG = data[2]\n",
    "#     sinyal_ECG = data[0]\n",
    "#     ppg_peaks,_ = find_peaks(sinyal_PPG, distance=60)\n",
    "    \n",
    "    \n",
    "#     start = 0\n",
    "#     end = 2\n",
    "    \n",
    "    \n",
    "#     for i in range (len(ppg_peaks)-1):\n",
    "#          #untuk handle error\n",
    "#          try: \n",
    "             \n",
    "#              PPG.append(sinyal_PPG[ppg_peaks[start]: ppg_peaks[end]])    \n",
    "#              ECG.append(sinyal_ECG[ppg_peaks[start]: ppg_peaks[end]])\n",
    "#              ABP.append(sinyal_ABP[ppg_peaks[start]: ppg_peaks[end]])\n",
    "            \n",
    "#          except IndexError:\n",
    "             \n",
    "#              PPG.append(sinyal_PPG[ppg_peaks[start]: ppg_peaks[end-1]])\n",
    "#              ECG.append(sinyal_ECG[ppg_peaks[start]: ppg_peaks[end-1]])\n",
    "#              ABP.append(sinyal_ABP[ppg_peaks[start]: ppg_peaks[end-1]])\n",
    "         \n",
    "             \n",
    "#          conv_ABP = np.hstack(ABP)\n",
    "#          sbp_peaks, _ = find_peaks(conv_ABP, distance =60)\n",
    "#          dbp_peaks, _ = find_peaks(-conv_ABP, distance = 60) \n",
    "            \n",
    "             \n",
    "        \n",
    "#          SBP.append(conv_ABP [sbp_peaks[start]])\n",
    "#          DBP.append(conv_ABP [dbp_peaks[start]])\n",
    "        \n",
    "#          print(start,end)\n",
    "            \n",
    "#          start = start+1\n",
    "#          end = end+1\n",
    "         \n",
    "\n",
    "         "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "11d14218",
   "metadata": {},
   "outputs": [],
   "source": [
    "# plt.plot(ECG [1])\n",
    "plt.plot(PPG [200])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "933693ad",
   "metadata": {},
   "outputs": [],
   "source": [
    "from scipy.interpolate import interp1d\n",
    "hasil_interpolasi_PPG = []\n",
    "# hasil_interpolasi_ECG = []\n",
    "Tabel_segmentasi_PPG = pd.DataFrame()\n",
    "# Tabel_segmentasi_ECG = pd.DataFrame()\n",
    "Tabel_segmentasi_SBP = pd.DataFrame()\n",
    "Tabel_segmentasi_DBP = pd.DataFrame()\n",
    "# PPG_SBP = []\n",
    "\n",
    "for x in PPG: \n",
    "   # print(len(x))\n",
    "        panjang_interpolasi = np.linspace(0,1,num = 200, endpoint=True)\n",
    "        PPG_sebelum_interpolasi= np.hstack(x)\n",
    "#         print(x)\n",
    "        if (len(PPG_sebelum_interpolasi) < 200) or (len(PPG_sebelum_interpolasi) > 200) :\n",
    "            x_interp_PPG= np.linspace(0, 1, len(PPG_sebelum_interpolasi))\n",
    "            f_interp_PPG = interp1d(x_interp_PPG, PPG_sebelum_interpolasi)\n",
    "            PPG_setelah_interpolasi = f_interp_PPG(panjang_interpolasi)\n",
    "            hasil_interpolasi_PPG.append(PPG_setelah_interpolasi)\n",
    "#     print(len(hasil_interpolasi_ECG))\n",
    "#     else :\n",
    "#         print('ini salah')\n",
    "#         print(len(x))\n",
    "        else:\n",
    "            PPG_setelah_interpolasi=PPG_sebelum_interpolasi\n",
    "            hasil_interpolasi_PPG.append(PPG_setelah_interpolasi)\n",
    "            \n",
    "# for y in ECG: \n",
    "#    # print(len(x))\n",
    "#         panjang_interpolasi = np.linspace(0,1,num = 200, endpoint=True)\n",
    "#         ECG_sebelum_interpolasi= np.hstack(x)\n",
    "# #         print(x)\n",
    "#         if (len(ECG_sebelum_interpolasi) < 200) or (len(ECG_sebelum_interpolasi) > 200) :\n",
    "#             x_interp_ECG= np.linspace(0, 1, len(ECG_sebelum_interpolasi))\n",
    "#             f_interp_ECG = interp1d(x_interp_ECG, ECG_sebelum_interpolasi)\n",
    "#             ECG_sebelum_interpolasi = f_interp_ECG(panjang_interpolasi)\n",
    "#             hasil_interpolasi_ECG.append(ECG_sebelum_interpolasi)\n",
    "# #     print(len(hasil_interpolasi_ECG))\n",
    "# #     else :\n",
    "# #         print('ini salah')\n",
    "# #         print(len(x))\n",
    "#         else:\n",
    "#             ECG_setelah_interpolasi=ECG_sebelum_interpolasi\n",
    "#             hasil_interpolasi_ECG.append(ECG_setelah_interpolasi)\n",
    "     \n",
    "    \n",
    "    \n",
    "    \n",
    "temp_PPG = pd.DataFrame(hasil_interpolasi_PPG)\n",
    "# temp_ECG = pd.DataFrame(hasil_interpolasi_ECG)\n",
    "temp_SBP = pd.DataFrame(SBP)\n",
    "temp_DBP = pd.DataFrame(DBP)\n",
    "Tabel_segmentasi_PPG = pd.concat([Tabel_segmentasi_PPG, temp_PPG], axis = 1, ignore_index = True)\n",
    "# Tabel_segmentasi_ECG = pd.concat([Tabel_segmentasi_ECG, temp_ECG], axis = 1, ignore_index = True)\n",
    "Tabel_segmentasi_SBP = pd.concat([Tabel_segmentasi_SBP, temp_SBP], axis = 1, ignore_index = True)\n",
    "Tabel_segmentasi_DBP = pd.concat([Tabel_segmentasi_DBP, temp_DBP], axis = 1, ignore_index = True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "607b1b23",
   "metadata": {},
   "outputs": [],
   "source": [
    "#Simpan masing-masing ECG, PPG, SBP, dan DBP\n",
    "\n",
    "PPG_hasil = temp_PPG\n",
    "PPG_hasil.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/add pasien excel/indenpendent dataset/test/PPG/3180470.csv')\n",
    "# ECG_hasil = temp_ECG\n",
    "# ECG_hasil.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/cek/ECG.csv')\n",
    "SBP_hasil = temp_SBP\n",
    "SBP_hasil.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/add pasien excel/indenpendent dataset/test/SBP/3180470.csv')\n",
    "DBP_hasil = temp_DBP\n",
    "DBP_hasil.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/add pasien excel/indenpendent dataset/test/DBP/3180470.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5b9b3824",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "# load_PPG = 'D:/MIMIC III CNN Prediction/Preprocessing/Data/10 pasien/82500/3770478/'\n",
    "# load_SBP = 'D:/MIMIC III CNN Prediction/Preprocessing/Data/10 pasien/82500/Label/SBP/3770478 200.csv'\n",
    "# load_DBP = 'D:/MIMIC III CNN Prediction/Preprocessing/Data/10 pasien/82500/Label/DBP/3770478 200.csv'\n",
    "\n",
    "# # Simpan_PPG.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/10 pasien/82500/PPG/200/train/3770478.csv')\n",
    "\n",
    "\n",
    "# # Label_train.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/10 pasien/82500/Label/DBP/200/train/3770478.csv')\n",
    "\n",
    "\n",
    "# # # #80% training\n",
    "# # Simpan_PPG = Data_PPG.loc[0:831]\n",
    "\n",
    "\n",
    "# # # #20% testing\n",
    "# # Simpan_PPG_test = Data_PPG.loc[832:1040]\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "# def potong(load_path, path_SBP, path_DBP, load=False): \n",
    "    \n",
    "#     if load == True:\n",
    "        \n",
    "#         Data_PPG = pd.read_csv(load_path)\n",
    "#         label_SBP = pd.read_csv(path_SBP)\n",
    "#         label_DBP = pd.read_csv(path_DBP)\n",
    "        \n",
    "#         #return 'data load'\n",
    "        \n",
    "#         train_PPG = len(Data_PPG)*0.8\n",
    "#         train_SBP = len(label_SBP)*0.8\n",
    "#         train_DBP = len(label_DBP)*0.8\n",
    "        \n",
    "        \n",
    "#     #Save 80% for training\n",
    "\n",
    "#     Simpan_PPG_train = Data_PPG.loc[0 : train_PPG]\n",
    "#     Simpan_PPG_train.drop(columns=['Unnamed: 0'])\n",
    "    \n",
    "    \n",
    "#     #Save 20% for testing\n",
    "\n",
    "#     Simpan_PPG_test = Data_PPG.loc[train_PPG : ]\n",
    "#     Simpan_PPG_test.drop(columns=['Unnamed: 0'])\n",
    "    \n",
    "    \n",
    "#     save_PPG_train = Simpan_PPG_train.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/CEK/PPG/')\n",
    "    \n",
    "#     return label_SBP, Data_PPG\n",
    "# #     # --------------------\n",
    "# #     # LABEL Training\n",
    "# #     # --------------------\n",
    "\n",
    "# #     Label_train = Label.loc[0:831]\n",
    "# #     Label_train\n",
    "    \n",
    "    \n",
    "# #     # --------------------\n",
    "# #     # LABEL Testing\n",
    "# #     # --------------------\n",
    "\n",
    "# #     Label_test = Label.loc[832:1040]\n",
    "# #     Label_test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4b1dbc80",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "load_PPG = 'D:/MIMIC III CNN Prediction/Preprocessing/Data/cek/PPG.csv'\n",
    "load_ECG = 'D:/MIMIC III CNN Prediction/Preprocessing/Data/cek/ECG.csv'\n",
    "load_SBP = 'D:/MIMIC III CNN Prediction/Preprocessing/Data/cek/SBP.csv'\n",
    "load_DBP = 'D:/MIMIC III CNN Prediction/Preprocessing/Data/cek/DBP.csv'\n",
    "\n",
    "# Simpan_PPG.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/10 pasien/82500/PPG/200/train/3770478.csv')\n",
    "\n",
    "\n",
    "# Label_train.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/10 pasien/82500/Label/DBP/200/train/3770478.csv')\n",
    "\n",
    "\n",
    "# # #80% training\n",
    "# Simpan_PPG = Data_PPG.loc[0:831]\n",
    "\n",
    "\n",
    "# # #20% testing\n",
    "# Simpan_PPG_test = Data_PPG.loc[832:1040]\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "# def potong(load_path_PPG, load_path_ECG, path_SBP, path_DBP, load=False): \n",
    "    \n",
    "# if load == True:\n",
    "\n",
    "Data_PPG = pd.read_csv(load_PPG)\n",
    "Data_ECG = pd.read_csv(load_ECG)\n",
    "label_SBP = pd.read_csv(load_SBP)\n",
    "label_DBP = pd.read_csv(load_DBP)\n",
    "\n",
    "#return 'data load'\n",
    "\n",
    "train_PPG = len(Data_PPG)*0.8\n",
    "train_ECG = len(Data_ECG)*0.8\n",
    "train_SBP = len(label_SBP)*0.8\n",
    "train_DBP = len(label_DBP)*0.8\n",
    "\n",
    "\n",
    "#Save 80% for training\n",
    "\n",
    "Simpan_PPG_train = Data_PPG.loc[0 : train_PPG]\n",
    "Simpan_PPG_train.drop(columns=['Unnamed: 0'])\n",
    "\n",
    "Simpan_ECG_train = Data_ECG.loc[0 : train_ECG]\n",
    "Simpan_ECG_train.drop(columns=['Unnamed: 0'])\n",
    "\n",
    "Simpan_SBP_train = label_SBP.loc[0 : train_SBP]\n",
    "Simpan_SBP_train.drop(columns=['Unnamed: 0'])\n",
    "\n",
    "Simpan_DBP_train = label_DBP.loc[0 : train_DBP]\n",
    "Simpan_DBP_train.drop(columns=['Unnamed: 0'])\n",
    "\n",
    "save_PPG_train = Simpan_PPG_train.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/cek/potong/train/PPG/pasien-1.csv')\n",
    "save_ECG_train = Simpan_ECG_train.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/cek/potong/train/ECG/pasien-1.csv')\n",
    "save_SBP_train = Simpan_SBP_train.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/cek/potong/train/SBP/pasien-1.csv')\n",
    "save_DBP_train = Simpan_DBP_train.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/cek/potong/train/DBP/pasien-1.csv')\n",
    "#Save 20% for testing\n",
    "\n",
    "Simpan_PPG_test = Data_PPG.loc[train_PPG : ]\n",
    "Simpan_PPG_test.drop(columns=['Unnamed: 0'])\n",
    "\n",
    "Simpan_ECG_test = Data_ECG.loc[train_ECG : ]\n",
    "Simpan_ECG_test.drop(columns=['Unnamed: 0'])\n",
    "\n",
    "Simpan_SBP_test = label_SBP.loc[train_SBP : ]\n",
    "Simpan_SBP_test.drop(columns=['Unnamed: 0'])\n",
    "\n",
    "Simpan_DBP_test = label_DBP.loc[train_DBP : ]\n",
    "Simpan_DBP_test.drop(columns=['Unnamed: 0'])\n",
    "\n",
    "save_PPG_train = Simpan_PPG_train.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/cek/potong/test/PPG/pasien-1.csv')\n",
    "save_ECG_train = Simpan_ECG_train.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/cek/potong/test/ECG/pasien-1.csv')\n",
    "save_SBP_train = Simpan_SBP_train.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/cek/potong/test/SBP/pasien-1.csv')\n",
    "save_DBP_train = Simpan_DBP_train.to_csv('D:/MIMIC III CNN Prediction/Preprocessing/Data/cek/potong/test/DBP/pasien-1.csv')\n",
    "\n",
    "#     return label_SBP, Data_PPG\n",
    "#     # --------------------\n",
    "#     # LABEL Training\n",
    "#     # --------------------\n",
    "\n",
    "#     Label_train = Label.loc[0:831]\n",
    "#     Label_train\n",
    "\n",
    "\n",
    "#     # --------------------\n",
    "#     # LABEL Testing\n",
    "#     # --------------------\n",
    "\n",
    "#     Label_test = Label.loc[832:1040]\n",
    "#     Label_test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "44f86d53",
   "metadata": {},
   "outputs": [],
   "source": [
    "potong(load=True, load_path = load_PPG, path_SBP = load_SBP, path_DBP = load_DBP)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "32fdfdfe",
   "metadata": {},
   "outputs": [],
   "source": [
    "len(testing)*0.8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "63e17823",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
